<!--
 * @作者: kerwin
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

</head>

<body>
    <script>
       Function.prototype.before= function(beforeFn){
            var _this = this
            return function(){
                //先进行前置函数调用
                beforeFn.apply(this,arguments)
                //执行原来的函数
                return _this.apply(this,arguments)
            }
       }

       Function.prototype.after= function(afterFn){
            var _this = this
            return function(){
                var result = _this.apply(this,arguments)
                //先进行前置函数调用
                afterFn.apply(this,arguments)
                //执行原来的函数
                return result
            }
       }

       function test(){
           console.log("1111111")
           return 111111
       }

       // test  = new Function()
       var test1 = test.before(function(){
            console.log("000000")
       }).after(function(){
           console.log("222222")
       })

       test1()
    </script>
</body>

</html>